{% extends 'base.html' %}

{% block title %}用户详情 - {{ user_sigle.username }} - Django RBAC 项目{% endblock %}

{% block content %}
<div class="container mx-auto px-4 py-8">
    <h1 class="text-2xl font-bold mb-6">用户详情: {{ user_sigle.username }}</h1>

    <div class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
        <div class="mb-4">
            <strong class="block text-gray-700 font-bold mb-2">用户名:</strong>
            <p>{{ user_sigle.username }}</p>
        </div>
        <div class="mb-4">
            <strong class="block text-gray-700 font-bold mb-2">邮箱:</strong>
            <p>{{ user_sigle.email }}</p>
        </div>
        <div class="mb-4">
            <strong class="block text-gray-700 font-bold mb-2">角色:</strong>
            <ul class="list-disc list-inside">
                {% for user_role in user_roles %}
                <li>{{ user_role.role.name }}</li>
                {% empty %}
                <li>该用户没有分配角色</li>
                {% endfor %}
            </ul>
        </div>
        <div class="mb-4">
            <strong class="block text-gray-700 font-bold mb-2">权限:</strong>
            <ul class="list-disc list-inside">
                {% for permission in user_permissions %}
                <li>{{ permission.name }} ({{ permission.codename }})</li>
                {% empty %}
                <li>该用户没有特定权限</li>
                {% endfor %}
            </ul>
        </div>
        <div class="mt-6">
            <a href="{% url 'assign_role_to_user' user.id %}" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
                分配角色
            </a>
            <a href="{% url 'user_list' %}" class="ml-4 inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800">
                返回用户列表
            </a>
        </div>
    </div>
</div>
{% endblock %}

